package com.op.studyingliteapp.bean;

import org.json.JSONObject;

import com.op.studyingliteapp.database.table.ResourceTable;

/**
 * @author handsome
 * @version 创建时间：2015年7月25日 下午8:36:55 类说明
 */
public class ResourceBean extends BaseBean {

	private String id;
	private String title;
	private String courseId;
	private String courseName;
	private UserBean userBean;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.contentValues.put(ResourceTable.COLUMN_ID, id);
		this.id = id;
	}

	public String getCourseName() {
		return courseName;
	}

	public void setCourseName(String courseName) {
		this.contentValues.put(ResourceTable.COLUMN_COURSE_NAME, courseName);
		this.courseName = courseName;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.contentValues.put(ResourceTable.COLUMN_TITLE, title);
		this.title = title;
	}

	public String getCourseId() {
		return courseId;
	}

	public void setCourseId(String courseId) {
		this.contentValues.put(ResourceTable.COLUMN_COURSE_ID, courseId);
		this.courseId = courseId;
	}

	public UserBean getUserBean() {
		return userBean;
	}

	public void setUserBean(UserBean userBean) {
		this.contentValues.put(ResourceTable.COLUMN_USER_ID, userBean.getId());
		this.contentValues.put(ResourceTable.COLUMN_USER_NAME, userBean.getName());
		this.contentValues.put(ResourceTable.COLUMN_USER_NUMBER, userBean.getNumber());
		this.contentValues.put(ResourceTable.COLUMN_USER_PHONE, userBean.getPhone());
		this.contentValues.put(ResourceTable.COLUMN_USER_EMAIL, userBean.getEmail());
		this.contentValues.put(ResourceTable.COLUMN_USER_IMAGE_URL, userBean.getImageUrl());
		this.contentValues.put(ResourceTable.COLUMN_USER_IS_USING, userBean.getIsUsing());
		this.contentValues.put(ResourceTable.COLUMN_USER_TYPE, userBean.getType());
		this.userBean = userBean;
	}

	@Override
	public void fillAttributeByJson(JSONObject jsonObject) {
		setId(getJsonValue(jsonObject, ResourceTable.TABLE_COURSE_RESOURCE, ResourceTable.COLUMN_ID));
		setCreateTime(getJsonValue(jsonObject, ResourceTable.TABLE_COURSE_RESOURCE, ResourceTable.COLUMN_CREATE_TIME));
		setUpdateTime(getJsonValue(jsonObject, ResourceTable.TABLE_COURSE_RESOURCE, ResourceTable.COLUMN_UPDATE_TIME));
		setTitle(getJsonValue(jsonObject, ResourceTable.TABLE_COURSE_RESOURCE, ResourceTable.COLUMN_TITLE));
		setCourseId(getJsonValue(jsonObject, ResourceTable.TABLE_COURSE_RESOURCE, ResourceTable.COLUMN_COURSE_ID));
		setCourseName(getJsonValue(jsonObject, ResourceTable.TABLE_COURSE_RESOURCE, ResourceTable.COLUMN_COURSE_NAME));

		// 填充UserBean,由于发送回来的Json内部暂不包含这些 所以先注释掉
		UserBean userBean = new UserBean();
		userBean.fillAttributeByJson(jsonObject);
		setUserBean(userBean);
	}
}
